package com.qiaofang.entity;

import com.qiaofang.common.model.BaseDomain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Formula;
import org.springframework.data.annotation.CreatedBy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * 商户
 */
@Data
@Entity
@Table(name = "tm_company")
public class Company extends BaseDomain {

    @ApiModelProperty("外部公司系统编号")
    @Column(name = "external_number")
    private String externalNumber;

    @ApiModelProperty("公司名称")
    @Column(name = "company_name")
    private String companyName;

    @ApiModelProperty("组合授权:[{key:authorization_service,values:[{no:1,alias:jrfw,remark:金融服务},{no:2,alias:ysfy,remark:一手房源},{no:3,alias:ysfy,remark:海外房源}]}]")
    @Column(name = "authorization")
    private String authorization;

    @ApiModelProperty("公司类型,对应系统参数表ID")
    @Column(name = "company_type")
    private Long companyType;

    @ApiModelProperty("公司类型辅助项")
    @Column(name = "company_type_aid")
    private Long companyTypeAid;

    @ApiModelProperty("公司地址")
    @Column(name = "adress")
    private String address;

    @ApiModelProperty("收款人名称")
    @Column(name = "payee")
    private String payee;

    @ApiModelProperty("银行卡号")
    @Column(name = "card_number")
    private String cardNumber;

    @ApiModelProperty("省份")
    @Column(name = "province")
    private Long province;

    @ApiModelProperty("城市")
    @Column(name = "city")
    private Long city;

    @ApiModelProperty("区")
    @Column(name = "zone")
    private Long zone;

    @ApiModelProperty("是否关联M2：0-否；1-是")
    @Column(name = "is_link_m2")
    private String merchant2;

    @ApiModelProperty("M2商户号")
    @Column(name = "merchant_code")
    private String merchantCode;

    @ApiModelProperty("域名")
    @Column(name = "domain")
    private String domain;

    @ApiModelProperty("是否需要佣金 1-是，0-否")
    @Column(name = "commission_flag")
    private String commissionFlag;

    @ApiModelProperty("是否需要短信，1-是，0-否")
    @Column(name = "message_flag")
    private String messageFlag;

    @ApiModelProperty("微信appId")
    @Column(name = "app_id")
    private String appId;

    @ApiModelProperty("微信appSecret")
    @Column(name = "app_secret")
    private String appSecret;

    @ApiModelProperty("审核状态：0待审核1审核失败2审核通过")
    @Column(name = "STATUS")
    private String status;

    @ApiModelProperty("公司代码")
    @Column(name = "company_code")
    private String companyCode;

    @ApiModelProperty("负责人姓名")
    @Column(name = "charge_man")
    private String chargeMan;

    @ApiModelProperty("手机号码")
    @Column(name = "phone")
    private String phone;

    @ApiModelProperty("分销首页展示开关 0: 关闭 1: 开启")
    @Column(name = "agency_index_switch")
    private String agencyIndexSwitch;

    @ApiModelProperty("楼盘对外开放开关: 0: 关闭 1: V10")
    @Column(name = "outside_switch")
    private String outsideSwitch;

    @ApiModelProperty("短信验真开关: 0: 关闭 1: 开启")
    @Column(name = "check_switch")
    private String checkSwitch;

    @ApiModelProperty("短信验真模板")
    @Column(name = "check_temp")
    private String checkTemp;

    @ApiModelProperty("公司简介")
    @Column(name = "introduction")
    private String introduction;

    @ApiModelProperty("")
    @Column(name = "company_uuid")
    private String companyUuid;

    @ApiModelProperty("重复报备开关")
    @Column(name = "repeat_report_switch")
    private String repeatReportSwitch;

    @ApiModelProperty("公司简称")
    @Column(name = "company_abbreviation")
    private String companyAbbreviation;

    @ApiModelProperty("是否删除，0-否，1-是")
    @Column(name = "del_flag")
    private String delFlag;

    @ApiModelProperty("是否M2参与客户判重：0-否；1-是")
    @Column(name = "is_check_m2_repeat")
    private String checkM2Repeat;
    
    @ApiModelProperty("是否开启微信小程序推送")
    @Column(name = "enable_weapp_msg")
    private int enableWeappMsg;

    @CreatedBy
    @ApiModelProperty("创建人id")
    @Column(name = "create_user_id")
    private Long createUserId;

    @Formula(value = " (select count(1) from tm_premises t where t.del_flag = 0 and t.company_id = id ) ")
    private Long numberOfProperties;

    @Formula(value = " (select count(1) from tr_company_relation t where t.del_flag = 0 and t.dev_company = id) ")
    private Long numberOfDistributors;

}
